package com.ruoyi.video.service;


import com.ruoyi.video.mapper.VideoEsMapper;
import com.ruoyi.video.pojo.VideoEsEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Description: new java files header..
 * 同步增量和创建映射实现层
 * @author 兰剑
 * @version 1.0
 * @date 2023/2/27 18:23
 */
@Component
@EnableScheduling
@Slf4j
public class VideoEsService {

//    @Autowired
//    ElasticsearchRestTemplate elasticsearchRestTemplate;
//    @Autowired
//    private VideoEsMapper videoEsMapper;
//    @Autowired
//    private RedisTemplate redisTemplate;
    
    
    
    /**@Description: 定时完成es同步添加
     * @param
     * @return 
     * @version v1.0
     * @author 兰剑
     * @date 2023/2/27 18:43
     */
//    @Scheduled(fixedDelay = 1000*10)
//    public void textEs(){
////        判断索引是否创建
//        if (!elasticsearchRestTemplate.indexOps(VideoEsEntity.class).exists()){
////            创建索引
//            elasticsearchRestTemplate.indexOps(VideoEsEntity.class).create();
////            创建映射
//            Document mapping = elasticsearchRestTemplate.indexOps(VideoEsEntity.class).createMapping();
//            elasticsearchRestTemplate.indexOps(VideoEsEntity.class).putMapping(mapping);
//        }
//        log.info("创建索引");
////        增量同步
//        String es_time =(String) redisTemplate.opsForValue().get("es_time");
//        List<VideoEsEntity> videoEsEntityList = videoEsMapper.selectList(null);
////        增量
//        log.info("增量同步");
//        for (VideoEsEntity videoEsEntity : videoEsEntityList) {
//            if (videoEsEntity.getGoodsStatus()==1){
//                elasticsearchRestTemplate.save(videoEsEntity);
////                修改标识
//                videoEsEntity.setGoodsStatus(2);
//                videoEsMapper.updateById(videoEsEntity);
//            }
//        }
//
//    }



}
